//
//  HomeImageAndLabelView.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/4/28.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "HomeImageAndLabelView.h"

@implementation HomeImageAndLabelView

/**  90  */
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat with = [UIScreen zj_screenWith] / 4;
        
        
        
        self.homeImageView = [UIImageView new];
        self.homeImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self addSubview:self.homeImageView];
        self.homeImageView.sd_layout
        .topSpaceToView(self,12 * [UIScreen zj_screenHScale])
        .heightIs(50 * [UIScreen zj_screenHScale])
        .widthIs(50 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self,(with - 50 * [UIScreen zj_screenHScale]) / 2);
        
        
        self.homeLabel = [UILabel new];
        self.homeLabel.textAlignment = NSTextAlignmentCenter;
    
        self.homeLabel.textColor = [UIColor textGrayColor];
        self.homeLabel.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
        [self addSubview:self.homeLabel];
        self.homeLabel.sd_layout
        .topSpaceToView(self.homeImageView,12 * [UIScreen zj_screenHScale])
        .widthIs(with).heightIs(12 * [UIScreen zj_screenHScale])
        .leftEqualToView(self);
        
        
        self.messageNumber = [UILabel new];
        self.messageNumber.backgroundColor = [UIColor whiteColor];
        self.messageNumber.layer.cornerRadius = 11 * [UIScreen zj_screenWScale];
        self.messageNumber.layer.masksToBounds = YES;
        self.messageNumber.textColor = [UIColor themeColor];
        self.messageNumber.textAlignment = NSTextAlignmentCenter;
        self.messageNumber.font = [UIFont systemFontOfSize:10 * [UIScreen zj_textFontScale]];
        [self addSubview: self.messageNumber];
        self.messageNumber.sd_layout
        .topSpaceToView(self, 8 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self.homeImageView, -3 * [UIScreen zj_screenWScale])
        .heightIs(22 * [UIScreen zj_screenWScale]).widthIs(22 * [UIScreen zj_screenWScale]);
        
        self.messageNumber.hidden = YES;
        
        
        self.redView = [UIView new];
        self.redView.backgroundColor = [UIColor zj_colorWithHexString:@"f24141"];
        self.redView.layer.cornerRadius = 5 * [UIScreen zj_screenWScale];
        self.redView.layer.masksToBounds = YES;
        [self addSubview: self.redView];
        self.redView.sd_layout
        .topSpaceToView(self, 8 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self.homeImageView, -3 * [UIScreen zj_screenWScale])
        .heightIs(10 * [UIScreen zj_screenWScale]).widthIs(10 * [UIScreen zj_screenWScale]);
        self.redView.hidden = YES;

        
        
    }
    return self;
}

- (void)setIsTop:(BOOL)isTop{
    _isTop = isTop;
    if (isTop) {
        self.homeImageView.sd_layout.topSpaceToView(self, 5 * [UIScreen zj_screenHScale]);
        [self.homeImageView updateLayout];
        self.homeLabel.sd_layout.topSpaceToView(self.homeImageView, 5 * [UIScreen zj_screenHScale]);
        [self.homeLabel updateLayout];
    }
    
}




@end
